local fenzhi = fk.CreateSkill {
  name = "lingling__fenzhi_zhudi",
}

Fk:loadTranslationTable {
  ["lingling__fenzhi_zhudi"] = "焚志",
  [":lingling__fenzhi_zhudi"] = "当你造成火焰伤害时，你可以移去两张“图”令此伤害+1并摸一张牌。",
  ["#lingling__fenzhi_zhudi-remove"] = "焚志：是否选择两张“图”移去令此伤害＋1",
}

fenzhi:addEffect(fk.DamageCaused, {
  anim_type = "offensive",
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(fenzhi.name) and data.damageType == fk.FireDamage
        and #player:getPile("lingling__zhudi_tu") >= 2
  end,
  on_cost = function(self, event, target, player, data)
    local room = player.room
    local cards = room:askToCards(player, {
      min_num = 2,
      max_num = 2,
      include_equip = false,
      skill_name = fenzhi.name,
      prompt = "#lingling__fenzhi_zhudi-remove",
      cancelable = true,
      pattern = ".|.|.|lingling__zhudi_tu",
      expand_pile = "lingling__zhudi_tu",
    })
    if #cards == 2 then
      event:setCostData(self, { cards = cards })
      return true
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local cards = event:getCostData(self).cards
    local move = room:moveCards {
      ids = cards,
      from = player,
      specialName = "lingling__zhudi_tu",
      toArea = Card.DiscardPile,
      proposer = player,
      moveReason = fk.ReasonPutIntoDiscardPile,
      moveVisible = true,
      skillName = fenzhi.name,
    }
    if move then
      data:changeDamage(1)
      player:drawCards(1)
    end
  end,
})

return fenzhi
